﻿using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xejen.Logger.NLog
{
    /// <summary>
    /// 表示仅适用于NLog的日志管理 
    /// </summary>
    /// <creator>marc</creator>
    public sealed class NLogManager 
    {
        private static ILoggerManager _instance;

        /// <inheritdoc cref="NLogManager"/>
        private NLogManager(ILoggerFactory loggerFactory) 
        {
        }

        /// <summary>
        /// 表示<see cref="LoggerManager{TLoggerFactory}"/>的实例
        /// </summary>
        public static ILoggerManager Instance()
        {
            if (_instance == null)
            {
                _instance = new LoggerManager(new NLogLoggerFactory());
            }

            return _instance;
        }

        /// <summary>
        /// 表示<see cref="LoggerManager{TLoggerFactory}"/>的实例
        /// </summary>
        /// <param name="options"><inheritdoc cref="NLogProviderOptions" path="/summary"/></param>
        public static ILoggerManager Instance(NLogProviderOptions options)
        {
            if (_instance == null)
            {
                _instance = new LoggerManager(new NLogLoggerFactory(options));
            }

            return _instance;
        }

        /// <summary>
        /// 表示<see cref="LoggerManager{TLoggerFactory}"/>的实例
        /// </summary>
        /// <param name="provider"><inheritdoc cref="NLogLoggerProvider" path="/summary"/></param>
        public static ILoggerManager Instance(NLogLoggerProvider provider)
        {
            if (_instance == null)
            {
                _instance = new LoggerManager(new NLogLoggerFactory(provider));
            }

            return _instance;
        }
    }
}
